require_relative "boot"
require "rails"
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

# 加载环境变量
Dotenv::Railtie.load

module QQMusic
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 6.1
    # Configuration for the application, engines, and railties goes here.
    #
    # These settings can be overridden in specific environments using the files
    # in config/environments, which are processed later.
    #
    # config.time_zone = "Central Time (US & Canada)"
    config.time_zone = 'Beijing'
    # config.eager_load_paths << Rails.root.join("extras")

    # 使用 docker, 需要把日志输出到STDOUT
    if ENV["RAILS_LOG_TO_STDOUT"].present?
      STDOUT.sync = true
      config.rails_semantic_logger.add_file_appender = false
      config.semantic_logger.add_appender(io: STDOUT, level: config.log_level, formatter: config.rails_semantic_logger.format)
    end

    # http://www.glitchwrks.com/2017/01/16/removing-cookies-sessions-rails-5
    # 部分盒子, cookies 只读, 导致 session 无用, 直接屏蔽
    config.session_store :disabled

    # 由于没有 session, csrf 可以关闭了
    config.action_controller.allow_forgery_protection = false

    # 确定一定以及肯定, 默认首部会导致天邑机顶盒打不开页面, 必须删除默认首部, 原因不明...
    # X-Content-Type-Options: nosniff
    # X-Download-Options: noopen
    # X-Frame-Options: SAMEORIGIN
    # X-Permitted-Cross-Domain-Policies: none
    # X-Request-Id: 8dae5e68-58e8-43f3-b0ca-0e8158bad2a7
    # X-Runtime: 0.103110
    # X-XSS-Protection: 1; mode=block
    config.action_dispatch.default_headers.clear
  end
end
